package pers.vinsonws.jianghu.clientwin.service;

import pers.vinsonws.jianghu.clientwin.global.Info;
import pers.vinsonws.jianghu.codeCompont.MsgEveryPro;
import pers.vinsonws.jianghu.tools.MergeMessage;

/**
 * @auther vinsonws
 * @date 2018/11/17 16:41
 */
public class ApplyChatRoomService {
    public static void sendApply(int chatRoomId){
        MsgEveryPro.Message.Builder builder = MsgEveryPro.Message.newBuilder();
        builder.setUserSendId(Info.id);
        builder.setType(3);
        builder.setDateLong(System.currentTimeMillis());
        String[] ss = {String.valueOf(chatRoomId)};
        builder.setMessage(MergeMessage.infoToMessage(ss, 3));
        Info.channel.writeAndFlush(builder.build());
    }

    public static void sendAdminSeeApply(int chatRoomid){
        MsgEveryPro.Message.Builder builder = MsgEveryPro.Message.newBuilder();
        builder.setUserSendId(Info.id);
        builder.setType(10);
        builder.setChatRoomOrUserRecvId(chatRoomid);
        builder.setDateLong(System.currentTimeMillis());

        Info.channel.writeAndFlush(builder.build());
    }

    public static void sendAdminOpreate(boolean pass, int applyUserId, int chatRoomId){
        MsgEveryPro.Message.Builder builder = MsgEveryPro.Message.newBuilder();
        builder.setUserSendId(Info.id);
        builder.setChatRoomOrUserRecvId(chatRoomId);
        builder.setDateLong(System.currentTimeMillis());
        builder.setType(11);
        int passNum = 0;
        if (pass) passNum = 1;
        String[] ss = {String.valueOf(passNum), String.valueOf(applyUserId)};
        builder.setMessage(MergeMessage.infoToMessage(ss, 11));


        Info.channel.writeAndFlush(builder.build());
    }
}
